import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/login' },
  {
    path: '/login',
    name: 'login',
    component: () =>
      import(/* webpackChunkName: "login" */ '@/views/login/index'),
    meta: {
      title: '登录'
    },
    hidden: true
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('@/views/home/index'),
    meta: {
      title: '主页'
    },
    hidden: true,
    redirect: '/welcome',
    children: [{
      path: '/welcome',
      name: 'welcome',
      component: () => import('@/views/welcome/index'),
      meta: {
        title: '首页'
      },
      hidden: true
    },
    {
      path: '/IndividualCenter',
      name: 'IndividualCenter',
      component: () => import('@/views/IndividualCenter/index'),
      meta: {
        title: '个人中心'
      },
      hidden: true
    },
    {
      path: '/users',
      name: 'users',
      component: () => import('@/views/userManagement/userList/index'),
      meta: {
        title: '用户列表'
      },
      hidden: true
    },
    {
      path: '/shopNews',
      name: 'shopNews',
      component: () => import('@/views/groupManagement/shopNews/index'),
      meta: {
        title: '商家信息'
      },
      hidden: true
    },
    {
      path: '/add',
      name: 'add',
      component: () => import('@/views/groupManagement/shopNews/components/add'),
      meta: {
        title: '添加材料'
      },
      hidden: true
    }

    ]
  }
]

const router = new VueRouter({
  routes
})

router.beforeEach((to, from, next) => {
  // if (to.path === '/login') return next()
  // const tokenStr = window.sessionStorage.getItem('token')
  // if (!tokenStr) return next('/login')
  next()
})
export default router
